<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to The XXXX</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="index.js"></script>
<script type="text/javascript" src="../js/jquery-1.6.3.js"></script>
<script type="text/javascript" src="../js/json.js"></script>
<script type="text/javascript">
	var xmlHttp;

	function createXMLHttpRequest() {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		}
	}
	
	
	//状态改变处理函数  
	function handleStateChange() {
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				parseResults();
			}
		}
	}
	//Callback Function  
	function parseResults() {
		var responseDiv = document.getElementById("serverResponse");
		if (responseDiv.hasChildNodes()) {
			responseDiv.removeChild(responseDiv.childNodes[0]);
		}

		var responseText = document.createTextNode(xmlHttp.responseText);
		responseDiv.appendChild(responseText);
	}
	
	function getInforObject() {
		return new Infor($("email").value, $("password").value);
	}
	
	//constitude the package of email and password  
	function MP(email, password) {
		this.email = email;
		this.password = password;
	}
	
	//The main function called buy BUTTON "login"
	function doJSON() {
		var mp = getInforObject();

		//使用JSON脚本库把JavaScript对象转换成Json字符串  
		var asJSON = JSON.stringify(mp);
		alert("Car object as JSON:\n " + asJSON);

		var url = "JSONExample?timeStamp=" + new Date().getTime();

		createXMLHttpRequest();
		xmlHttp.open("POST", url, true);
		xmlHttp.onreadystatechange = handleStateChange;
		xmlHttp.setRequestHeader("Content-Type",
				"application/x-www-form-urlencoded");
		xmlHttp.send(asJSON);
	}
</script>
</head>
<body>
	<input type="button" value="def" onclick="def" /> 当前时间为<%=new Date().toString()%>
	<form action="#" method="post">
		<p>&nbsp;</p>
		<p>
			<a href="RegisterPage.jsp">Register</a>
		</p>
		<p>Please login before you process:</p>
		<p>
			Email&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="email" size="30"
				maxlength="30" onchange="onchange_email()" />&nbsp;<label
				id="infor_email"></label>
		</p>
		<p>
			Password&nbsp;<input type="password" id="password" size="30"
				maxlength="30" onchange="onchange_psw()" />&nbsp;<label
				id="infor_psw"></label>
		</p>
		<p>
			Department<br /> <label><input type="radio"
				name="department" value="Student" id="department0" checked="true" />
				Student</label><br /> <label><input type="radio" name="department"
				value="Proffesioner" id="department1" /> Proffesioner</label><br /> <label><input
				type="radio" name="department" value="Graduate" id="department2" />
				Graduate</label><br /> <label><input type="radio" name="department"
				value="Administrator" id="department3" /> Administrator</label><br />
		</p>
		<p>
			<label for="button2"></label><input type="submit" name="button"
				id="btn_login" value="LOGIN" onclick="doJSON()" /> <label
				for="button2"></label><input type="reset" name="button2"
				id="btn_reset" value="RESET" /><br />
		</p>
		<label id="serverResponse"></label>
	</form>
</body>
</html>
